const read = require('./src/read')
const write = require('./src/write')

const fileName = [
  {
    zh: 'prodComp',
    en: 'prodComp-en',
    name: '产品组件',
  },
  {
    zh: 'prodComp22222',
    en: 'prodComp2323-en',
    name: '业务组件',
  },
  {
    zh: 'ProdTableConfig',
    en: 'ProdTableConfig-en',
    name: '单层组件',
  },
]

const datas = []

for (let i = 0; i < fileName.length; i++) {
  const item = fileName[i]
  const zhDatas = read(item.zh)
  const enDatas = read(item.en)
  const list = []

  for (const key in zhDatas) {
    if (Object.hasOwnProperty.call(zhDatas, key)) {
      const one = zhDatas[key]
      const fileObj = {
        fileName: key,
        datas: [],
      }

      for (const key_c in one) {
        if (Object.hasOwnProperty.call(one, key_c)) {
          const one_c = one[key_c]
          fileObj.datas.push({
            key: key_c,
            zh: one_c,
            en: enDatas[key][key_c],
          })
        }
      }

      list.push(fileObj)
    }
  }

  datas.push({
    name: item.name,
    list,
  })
}

write(datas, 'consoleI18n_test3')
